<?php

namespace Database\Seeders;

use App\Helper\KeysHandler;
use App\Models\Config;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Cache;

class ConfigSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $config = [
            [
                'name' => 'web_name',
                'content' => '江西盟造',
                'description' => '网站名称',
            ],
            [
                'name' => 'keyword',
                'content' => '',
                'description' => '关键词',
            ],
            [
                'name' => 'description',
                'content' => '',
                'description' => '网站描述',
            ],
            [
                'name' => 'logo',
                'content' => '',
                'description' => '网站Logo',
            ],
            [
                'name' => 'banner',
                'content' => '',
                'description' => '网站Banner',
            ],
            [
                'name' => 'icp',
                'content' => '',
                'description' => '备案信息',
            ],
            [
                'name' => 'copyright',
                'content' => '',
                'description' => '版权信息',
            ],
            [
                'name' => 'material_inadequate',
                'content' => '',
                'description' => '资料不足提示',
            ],
        ];

        foreach ($config as $key => $item) {
            if (Config::query()->where('name', '=', $item['name'])->exists()) {
                unset($config[$key]);
            }
        }
        if (count($config)) {
            Config::insert($config);
            Cache::forget(KeysHandler::CONFIG);
        }
    }
}
